﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [ObterEmailsUltimoJogo]
	-- Add the parameters for the stored procedure here	
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	Declare @IDJogos as numeric

	Select @IDJogos = (IDJogos) From Jogos Order by 1 Asc	

	SELECT 
	U.IDUser,
	U.NomeUtilizador,
	U.Email
	From Utilizadores U
	Inner Join ConstituicaoEquipas CE
	ON U.IDUser = CE.IDJogador
	Where CE.IDJogos = @IDJogos And U.Email is not Null
	Order By U.IDUser Asc

END